<%-- 
    Document   : DangNhap
    Created on : Oct 16, 2012, 7:49:13 AM
    Author     : DAT
--%>

<%@page import="dao.LoaiSanPhamDAO"%>
<%@page import="pojo.LoaiSanPham"%>
<%@page import="pojo.SanPham"%>
<%@page import="java.util.List"%>
<%@page import="dao.ThuongHieuDAO"%>
<%@page import="pojo.ThuongHieu"%>
<%@page import="dao.SanPhamDAO"%>
<%@page import="dao.KhachHangDAO"%>
<%@page import="pojo.KhachHang"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Shoes.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
    </head>

    <body background="images/Blue_Background.png">
        <%
            String maThuongHieu = "1";
            String giaBan = "500000";

            ThuongHieu ThuongHieu = ThuongHieuDAO.layThongTinThuongHieu(Integer.parseInt(maThuongHieu));
            int soLuongSanPhamTrenTrang = 2;
            if (request.getParameter("soLuongSanPhamTrenTrang") != null) {
                soLuongSanPhamTrenTrang = Integer.parseInt(request.getParameter("soLuongSanPhamTrenTrang"));
            }
            int trang = 1;
            if (request.getParameter("trang") != null) {
                trang = Integer.parseInt(request.getParameter("trang"));
            }

            String thongBao = "";
            String dangNhap = request.getParameter("dangNhap.x");
            String name = "";
            if (dangNhap != null) {
                KhachHang khachHang = KhachHangDAO.layKhachHang(request.getParameter("tenDangNhap"));
                if (khachHang != null) {
                    if (!khachHang.getMatKhau().equals(request.getParameter("matKhau"))) {
                        thongBao = "Tên đăng nhập hoặc mật khẩu không phù hợp!";
                    } else {
                        name = request.getParameter("tenDangNhap");
                        session.setAttribute("username", name);
                        response.sendRedirect("Model3_TrangChu.jsp");
                        return;
                    }
                } else {
                    thongBao = "Tên đăng nhập hoặc mật khẩu không phù hợp!";
                }
            } else {
                thongBao = "Loi!";
            }
        %>
        <table width="1034" height="455" align="center" border="1" bordercolor="#FFFFFF">
            <tr align="center">
                <td colspan="5" valign="middle"><img src="images/BannerShoes.gif" width="1024" height="247"/></td>
            </tr>
            <tr>
                <td width="200" align="center"><a href="TrangChu.jsp"><img src="images/Button-Trangchu.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangDangKy"><img src="images/Button-Nam.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangChu"><img src="images/Button-Nu.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangChu"><img src="images/Button-Treem.gif" width="179" height="48"/></a></td>
                <td width="200" align="center"><a href="TrangChu"><img src="images/Button-Gioithieu.gif" width="179" height="48"/></a></td>
            </tr>
            <tr align="center">
                <%
                    List<ThuongHieu> list = ThuongHieuDAO.layDanhSach();
                    List<LoaiSanPham> dsLoaiSP = LoaiSanPhamDAO.layDanhSachLoaiSanPham();
                    List<SanPham> dsSP = SanPhamDAO.layDanhSachSanPham();
                %>

                <!-- bat dau phan tim kiem-->
                <form action="TimKiem.jsp">
                    <td colspan="5">
                        <p align="right"><font color="#0066FF"><strong>Tìm kiếm theo:</strong></font>

                            <select name="thuongHieu" size="1" style="width:15%">
                                <option value="1" selected="selected">--Chọn thương hiệu--</option>
                                <%
                                    for (int i = 0; i < list.size(); i++) {
                                        ThuongHieu thuongHieu = list.get(i);
                                %>
                                <option value="<%=thuongHieu.getMaThuongHieu()%>"><%=thuongHieu.getTenThuongHieu()%></option>
                                <%}
                                    if (request.getParameter("thuongHieu") != null) {
                                        maThuongHieu = request.getParameter("thuongHieu");
                                    }
                                %>
                            </select>

                            <select name="loaiSanPham" style="width:15%">
                                <option value="Tất cả" selected="selected">--Chọn loại--</option>
                                <%
                                    for (int i = 0; i < dsLoaiSP.size(); i++) {
                                        LoaiSanPham loaiSanPham = dsLoaiSP.get(i);
                                %>
                                <option value="<%= loaiSanPham.getMaLoaiSanPham()%>"><%=loaiSanPham.getTenLoaiSanPham()%></option>
                                <% }
                                    String maLoai = "L001";
                                    if (request.getParameter("loaiSanPham") != null) {
                                        maLoai = request.getParameter("loaiSanPham");
                                    }
                                %>
                            </select>

                            <select name="kichCo" style="width:15%">
                                <option value="1" selected="selected">--Chọn kích cỡ--</option>
                                <%
                                    for (int i = 0; i < dsSP.size(); i++) {
                                        SanPham sp = dsSP.get(i);
                                %>
                                <option value=<%= sp.getSize()%> ><%= sp.getSize()%></option>
                                <% }
                                    String size = "1";
                                    if (request.getParameter("kichCo") != null) {
                                        size = request.getParameter("kichCo");
                                    }
                                %>
                            </select>

                            <select name="giaBan" style="width:15%">
                                <option value="Tất cả" selected="selected">--Chọn giá--</option>
                                <option value="150">&lt; 150,000</option>
                                <option >150,000 - 250,000</option>
                                <option>250,000 -500,000</option>
                                <option>&gt; 500,000</option>
                            </select>

                            <input type="submit" value="Tìm kiếm" name="timKiem" >

                            </input>           
                        </p>
                        <!--ket thuc tim kiem-->
                    </td>
                </form>
            </tr>
            <tr>
                <td height="294" align="center">
                    <table width="100%" height="190" cellpadding="5" cellspacing="0" background="images/background.jpg">
                        <tr>
                            <td height="30" align="center" background="images/Bartop.gif"><p><strong><font color="#FFFFFF">THƯƠNG HIỆU</font></strong></p></td>
                        </tr>
                        <!--BatDauThuongHieu-->
                        <%
                            for (int i = 0; i < list.size(); i++) {
                                ThuongHieu dm = list.get(i);
                        %>
                        <tr>
                            <td>               
                                <a href="DanhSachSanPham.jsp?maThuongHieu=<%=dm.getMaThuongHieu()%>"><%=dm.getTenThuongHieu()%></a></td>
                        </tr>  
                        <%}%>
                    </table>
                    <table width="100%" background="images/background.jpg" >
                        <tr>
                            <td colspan="2" height="30" align="center" background="images/Bartop.gif"><p><strong><font color="#FFFFFF">LOẠI SẢN PHẨM</font></strong></p></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/kids_dep.gif"/></td>
                            <td width="137"><a><font color="#0000FF" >Dép</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/batavai_Icon.png"/></td>
                            <td width="137"><a><font color="#0000FF" >Giầy thể thao</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/men_daytay.gif"/></td>
                            <td width="137"><a><font color="#0000FF">Giầy tây</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/nu_thoitrang.gif"/></td>
                            <td width="137"><font color="#0000FF"><a>Giầy cao gót</a></font></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/men_sandal.gif"/></td>
                            <td width="137"><a><font color="#0000FF">Sandals</font></a></td>
                        </tr>
                        <tr>
                            <td width="51"><img src="images/kids_hai.gif"/></td>
                            <td width="137"><font color="#0000FF">Hài</font></td>
                        </tr>
                    </table></td>
                <td colspan="4" valign="top"><!-- InstanceBeginEditable name="MainContent" -->
                    <form action="DangNhap.jsp" method="post">
                        <table width="822" height="64" style="border: 4px #999  outset" cellspacing="0"  >
                            <tr >
                                <td colspan="2" valign="top" bgcolor="#CCCCCC"><strong>ĐĂNG NHẬP THÀNH VIÊN</strong></td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>                            
                            <!--bat dau dang nhap thanh vien-->
                            <tr>
                                <td width="297">Tên đăng nhập:</td>
                                <td width="513">
                                    <label for="tenDangNhap"></label>
                                    <input type="text" name="tenDangNhap" id="tenDangNhap" 
                                           <%
                                               if (request.getParameter("tenDangNhap") != null) {
                                           %>
                                           value="<%= request.getParameter("tenDangNhap")%>"
                                           <%}%>
                                           /> 
                                    <%
                                        if (request.getParameter("tenDangNhap") == "") {
                                            thongBao = "Bạn phải nhập đầy đủ thông tin đăng nhập";
                                        }
                                    %>
                                </td>
                            </tr>
                            <tr>
                                <td>Mật khẩu:</td>
                                <td>
                                    <label for="matKhau"></label>
                                    <input type="password" name="matKhau" id="matKhau" ></input>
                                    <%
                                        if (request.getParameter("matKhau") == "") {
                                            thongBao = "Bạn phải nhập đầy đủ thông tin đăng nhập";
                                        }
                                    %>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="ghiNho" id="ghiNho" />                                  
                                    <label for="ghiNho"></label>
                                    Ghi nhớ
                                </td>
                                <td>
                                    <input type="image"src="images/Button-DangNhap.png" width="150" height="38" name="dangNhap" />
                                    <label><font color="#FF0000" ><%= thongBao%></font></label>
                                </td>
                            </tr>
                            <tr>
                                <td><a href="#" style="text-decoration:none">Không thể truy cập vào tài khoản của bạn?</a></td>
                                <td><a href="DangKy.jsp" style="text-decoration:none" >Đăng ký thành viên!</a></td>
                            </tr>
                        </table>
                    </form>
                    <!-- InstanceEndEditable --></td>
            </tr>
            <tr align="center">
                <td colspan="5" background="images/Bartop.gif">&nbsp;</td>
            </tr>
            <tr align="center">
                <td colspan="5">
                    <p align="right"><a style="text-decoration:none" href="DangNhap.jsp"><font color="#0000FF"><strong>Đăng nhập &nbsp;&nbsp;  </strong></font></a> <a style="text-decoration:none" href="DangKy.jsp"><font color="#0000FF"><strong>Đăng ký&nbsp;</strong></font></a></p></td>
            </tr>
            <tr align="center">
                <td colspan="5"><strong>@ 2012 Le Khanh Nhac </strong> <a href="#" target="_blank">Terms &amp; Privacy</a></td>
            </tr>
        </table>
    </body>
    <!-- InstanceEnd --></html>

